#!/usr/bin/env bash

#get this script real directory
SOURCE="$0"
while [ -h "$SOURCE"  ]; do # resolve $SOURCE until the file is no longer a symlink
    this_script_dir="$( cd -P "$( dirname "$SOURCE"  )" && pwd  )"
    SOURCE="$(readlink "$SOURCE")"
    # if $SOURCE was a relative symlink, 
    #we need to resolve it relative to the path 
    #where the symlink file was located
    [[ $SOURCE != /*  ]] && SOURCE="$this_script_dir/$SOURCE"
done
this_script_dir="$( cd -P "$( dirname "$SOURCE"  )" && pwd  )"

log_level=info
source $this_script_dir/global.sh

#./vscp.sh --src_username=vi2 --src_ip=192.168.1.180 --src_port=22 --src_path=/home/vi2/test.txt --dst_path=tmp --log_level=info --src_passwd=j 

source ./global.sh
###ip=192.168.180
###ip2=192.168.180.1
###ip3=192.j68.180.1
###ip4=yuanji.tech
###ip5=dev.yuanji.tec
####
###check_ip_valid $ip $ip2 $ip3 $ip4 $ip5 dev.yj.com p1.dev.yj.com
###echo "checkip ret:$?"
###
###exit 0


test1()
{
    #date >> tmp/test.txt

    ./vscp.sh --src_path=./tmp/test.txt --dst_username=vi2 --dst_ip=192.168.1.180 --dst_port=22 --dst_path=/home/vi2/tmp2 --log_level=info --dst_passwd=j 
    #./vscp.sh --src_path=./tmp/test.txt --dst_username=vi2 --dst_ip=192.168.1.180 --dst_port=22 --dst_path=/home/vi2/tmp2 --log_level=debug --dst_passwd=j 

    mkdir -p tmp
    #./vscp.sh --src_username=vi2 --src_ip=192.168.1.180 --src_port=22 --src_path=/home/vi2/test.txt --dst_path=tmp --log_level=info --src_passwd=j 
    ./vscp.sh --src_path=./tmp/test.txt --dst_username=vi2 --dst_ip=192.168.1.180 --dst_port=22 --dst_path=/home/vi2/tmp2 --log_level=info --dst_passwd=j 
    #
    ./vscp.sh  \
        --src_username=vi2 --src_ip=192.168.1.180 --src_port=22 --src_path=/home/vi2/test.txt --src_passwd=j \
        --dst_username=vi2 --dst_ip=192.168.1.180 --dst_port=22 --dst_path=/home/vi2/tmp3 --log_level=$log_level --dst_passwd=j 


}

test2()
{
    #date >> tmp/test.txt

    ./vscp.sh --src_path="~/tmp/tmp 2/m1" --dst_username=vi2 --dst_ip=192.168.31.8 --dst_port=22 --dst_path=/home/vi2/m11 --log_level=$log_level --dst_passwd=123
}

test3()
{
    #date >> tmp/test.txt

    #./vrsync.sh --src_path=~/tmp/m1/ --dst_username=vi2 --dst_ip=192.168.31.8 --dst_port=22 --dst_path=/home/vi2/m11 --log_level=$log_level --dst_passwd=123
    ./vrsync.sh --src_path=$HOME/tmp/m1 --dst_username=vi2 --dst_ip=192.168.31.8 --dst_port=22 --dst_path=~/m11 --log_level=$log_level --dst_passwd=123
}

main()
{
    #test2
    test3
}

main
exit 0

